package entity;

import lombok.Data;
import view.TankClientView.Screen;

import java.util.Random;

/**
 * 地图坐标
 */
@Data
public class Position {

	/**
	 * x 坐标
	 */
	private int x;
	/**
	 * y 坐标
	 */
	private int y;
	
	public Position(int x,int y) {
		this.x = x ;
		this.y = y;
	}

	public static Position getRandomPosition(int width,int height) {
		int x = new Random().nextInt(width-Tank.TWidth-Tank.GunLength);
		int y = new Random().nextInt(height-Tank.THeight-Tank.GunLength);
		return new Position(x, y);
	}
	
	public static boolean isOverRound(Position position) {
		return position.getX() < -20 || position.getX() > Screen.WIDTH + 20 || position.getY() < -20 || position.getY() > Screen.HEIGHT + 20;
	}
	
}
